

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.AirlineReservationServiceProxy;
import bean.ReservationDetails;
import constants.AirlineReservationServiceConstants;

/**
 * Servlet implementation class viewAllReservationServlet
 */
public class viewAllReservationServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		AirlineReservationServiceProxy proxy = new AirlineReservationServiceProxy(
				AirlineReservationServiceConstants.SERVICE_URL);
		
		long confirmationNumber = Long.parseLong(req.getParameter("cunfirmationNumber"));
		
		ReservationDetails[] reservationDetails = proxy.viewAllReservation(confirmationNumber);
		
		List<ReservationDetails> lstAllReservationDetails = new ArrayList<ReservationDetails>();
		
		if(reservationDetails!= null)
			lstAllReservationDetails = Arrays.asList(reservationDetails);
		
		
		
		
		req.setAttribute("lstAllReservationDetails", lstAllReservationDetails);
		
		req.getRequestDispatcher("viewAllReservations.jsp").forward(req,resp);

	}

}
